<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function foo() {
        var myName = '极客时间'
        let test1 = 1
        const test2 = 2
        var innerBar = {
          getName: function () {
            console.log(test1)
            return myName
          },
          setName: function (newName) {
            myName = newName
          },
        }
        return innerBar
      }
      var bar = foo()
      bar.setName('极客邦')
      bar.getName()
      console.log(bar.getName())
    </script>
  </body>
</html>
